﻿using System.Configuration;

namespace gnet1.Models
{
  public class ANetViewModel
  {
    public string TimeStamp { get; set; }
    public string Sequence { get; set; }
    public string Login { get; set; }
    public string TransactionKey { get; set; }
    public string Hash { get; set;  }
    public decimal Amount { get; set; }

    public ANetViewModel(decimal amount)
    {
      Amount = amount;
      TimeStamp = AuthorizeNet.Crypto.GenerateTimestamp().ToString();
      Sequence = AuthorizeNet.Crypto.GenerateSequence();
      TransactionKey = ConfigurationManager.AppSettings["AUTHORIZE_NET_TRANSACTION_KEY"];
      Login = ConfigurationManager.AppSettings["AUTHORIZE_NET_LOGIN"];
      Hash = AuthorizeNet.Crypto.GenerateFingerprint(TransactionKey, Login, Amount, Sequence, TimeStamp);                                            
    }
  }
}